package homework19;
public class Company { //    void wages(SalariedEmployee a, int month) {
//        a.sendMoney(month) ;
//    }
//    void wages(HourlyEmployee a, int month) {
//        a.sendMoney(month) ;
//    }
//    void wages(SalesEmployee a, int month) {
//        a.sendMoney(month) ;
//    }
    void wages(Object a, int month) {
        a.getClass();
        // System.out.println(a.getClass().toString());
        if (a instanceof SalariedEmployee) {
            //把a类强转成 SalariedEmployee
           System.out.print(((SalariedEmployee) a).name);
            SalariedEmployee b = (SalariedEmployee) a;
            b.sendMoney(month);
        } else if (a instanceof HourlyEmployee) {
            //把a类强转成 HourlyEmployee
            System.out.print(((HourlyEmployee) a).name);
            HourlyEmployee b = (HourlyEmployee) a;
            b.sendMoney(month);
        } else if (a instanceof SalesEmployee) {
            //把a类强转成 SalesEmployee
            System.out.print(((SalesEmployee) a).name);
            SalesEmployee b = (SalesEmployee) a;
            b.sendMoney(month);
        }
    }
    //主要是我有点糊涂，想不到用数组接类后应该怎么区分类，干脆直接用反射吧

}
